Skip to content

test: add missing tests for toolbox pre and pos slots in RoomHeader#39480

Open
sahillllllllll-bit wants to merge 1 commit intoRocketChat:developfrom
sahillllllllll-bit:test-roomheader-toolbox-pre-pos
Open

test: add missing tests for toolbox pre and pos slots in RoomHeader#39480
sahillllllllll-bit wants to merge 1 commit intoRocketChat:developfrom
sahillllllllll-bit:test-roomheader-toolbox-pre-pos

Conversation

@sahillllllllll-bit
Copy link
Contributor

@sahillllllllll-bit sahillllllllll-bit commented Mar 9, 2026

While working on my GSoC proposal related to Room Header button ordering, I was exploring the RoomHeader component and its associated tests. During this review, I noticed that the component supports additional toolbox slot props (toolbox.pre and toolbox.pos) but the current test suite does not verify their rendering.

Specifically, the RoomHeader implementation renders these slots inside HeaderToolbar:

{slots?.toolbox?.pre}
{slots?.toolbox?.content || <RoomToolbox />}
{slots?.toolbox?.pos}

However, the existing tests only cover:

default toolbox rendering

hidden toolbox behavior

custom toolbox.content

There are no tests validating that toolbox.pre and toolbox.pos are rendered correctly.

Changes

This PR adds two small test cases to improve coverage:

  • Verify that slots.toolbox.pre renders inside the toolbar.
  • Verify that slots.toolbox.pos renders inside the toolbar.

Summary by CodeRabbit

  • Tests
    • Added test coverage for toolbox slot rendering functionality.

@sahillllllllll-bit sahillllllllll-bit requested a review from a team as a code owner March 9, 2026 18:01
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 9, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: d81bdc5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Walkthrough

Two new test cases were added to RoomHeader.spec.tsx to verify the rendering of toolbox slots. The tests check that the toolbox.pre and toolbox.pos slots correctly render their provided content. No existing functionality was modified.

Changes

Cohort / File(s) Summary
Test Additions
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
Added two new test cases to verify rendering of toolbox.pre and toolbox.pos slots within the RoomHeader component.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding missing tests for toolbox pre and pos slots in RoomHeader component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/client/views/room/Header/RoomHeader.spec.tsx">

<violation number="1" location="apps/meteor/client/views/room/Header/RoomHeader.spec.tsx:66">
P2: The new pre/pos slot tests only assert global text presence and do not verify that slot content is rendered inside the toolbar in the intended order.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx (1)

64-71: Scope these assertions to the toolbar.

On Line 66 and Line 71, getByText only proves the slot content exists somewhere in the document. It would miss a regression where toolbox.pre / toolbox.pos render outside HeaderToolbar, which is the behavior this PR is meant to cover.

🔍 Suggested test tightening
-import { render, screen } from '@testing-library/react';
+import { render, screen, within } from '@testing-library/react';
…
 		it('should render toolbox pre slot', () => {
 			render(<RoomHeader room={mockedRoom} slots={{ toolbox: { pre: <div>Pre Item</div> } }} />, { wrapper: appRoot });
-			expect(screen.getByText('Pre Item')).toBeInTheDocument();
+			expect(within(screen.getByLabelText('Toolbox_room_actions')).getByText('Pre Item')).toBeInTheDocument();
 		});

 		it('should render toolbox pos slot', () => {
 			render(<RoomHeader room={mockedRoom} slots={{ toolbox: { pos: <div>Pos Item</div> } }} />, { wrapper: appRoot });
-			expect(screen.getByText('Pos Item')).toBeInTheDocument();
+			expect(within(screen.getByLabelText('Toolbox_room_actions')).getByText('Pos Item')).toBeInTheDocument();
 		});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/room/Header/RoomHeader.spec.tsx` around lines 64 -
71, The assertions in RoomHeader.spec.tsx are too broad — replace global
getByText checks with queries scoped to the HeaderToolbar so we verify
toolbox.pre and toolbox.pos render inside the toolbar. Import and use within
from `@testing-library/react`, locate the toolbar element rendered by RoomHeader
(e.g., query the HeaderToolbar via role/testid/class used in RoomHeader) and
then assert using within(toolbarElement).getByText('Pre Item') and
within(toolbarElement).getByText('Pos Item') for the two tests (update both
tests referencing toolbox pre/pos and ensure you locate the same HeaderToolbar
element in each).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/client/views/room/Header/RoomHeader.spec.tsx`:
- Around line 64-71: The assertions in RoomHeader.spec.tsx are too broad —
replace global getByText checks with queries scoped to the HeaderToolbar so we
verify toolbox.pre and toolbox.pos render inside the toolbar. Import and use
within from `@testing-library/react`, locate the toolbar element rendered by
RoomHeader (e.g., query the HeaderToolbar via role/testid/class used in
RoomHeader) and then assert using within(toolbarElement).getByText('Pre Item')
and within(toolbarElement).getByText('Pos Item') for the two tests (update both
tests referencing toolbox pre/pos and ensure you locate the same HeaderToolbar
element in each).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d0610de-61a1-4820-97b6-2d00fcda6cae

📥 Commits

Reviewing files that changed from the base of the PR and between 692a891 and d81bdc5.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
🧠 Learnings (11)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Prefer web-first assertions (`toBeVisible`, `toHaveText`, etc.) in Playwright tests

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2026-02-24T19:36:55.089Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/views/room/Header/RoomHeader.spec.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant